<template>
  <div style="height:100%;width:100%;position:relative;">
      <div class="pagetop">
          <div style="width:100%;float:left">
              <table style="font-size:12px;white-space: nowrap;" border="0" class="table1style">
                  <tr>
                      <td align="right">报告单元</td>
                      <td>
                          <el-select v-model="rptunitid" @dblclick.native="popMultipleChk(rptunitid,'rptunitid',rptunitOption,'请选择报告单元')" filterable clearable style="width:100%" @change="rptunitchange" :disabled="StartAutoCheckFlag">
                              <el-option v-for="(item,index) in rptunitOption" :key="index" :value="item.data" :label="item.display"></el-option>
                          </el-select>
                      </td>

                      <td align="right">病人类型</td>
                      <td>
                          <el-select v-model="pattype" @dblclick.native="popMultipleChk(pattype,'pattype',pattypeOption,'病人类型选择')" filterable clearable style="width:100%" :disabled="StartAutoCheckFlag">
                              <el-option v-for="(item,index) in pattypeOption" :value="item.data" :label="item.display" :key="index"></el-option>
                          </el-select>
                      </td>
                      <td>起始时间</td>
                      <td>
                          <el-date-picker type="datetime" placeholder="选择日期" v-model="begindate" value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%;" :disabled="StartAutoCheckFlag"></el-date-picker>
                      </td>
                      <td>审核者</td>
                      <td>
                          <el-input v-model="checkuser" style="width: 100%;" readonly @dblclick.native="LoginPage(1)" :disabled="StartAutoCheckFlag"></el-input>
                      </td>
                  </tr>
                  <tr>
                      <td align="right">仪器</td>
                      <td colspan="3">
                          <el-select v-model="instrid" @dblclick.native="popMultipleChk(instrid,'instrid',instrOption,'仪器选择')" filterable clearable style="width:100%" :disabled="StartAutoCheckFlag">
                              <el-option v-for="(item,index) in instrOption" :value="item.data" :label="item.display" :key="index"></el-option>
                          </el-select>
                      </td>
                      <td>截止时间</td>
                      <td>
                          <el-date-picker type="datetime" placeholder="选择日期" v-model="enddate" value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%;" :disabled="StartAutoCheckFlag"></el-date-picker>
                      </td>
                      <td>检验者</td>
                      <td>
                          <el-input v-model="reportuser" style="width: 100%;" readonly @dblclick.native="LoginPage(2)" :disabled="StartAutoCheckFlag"></el-input>
                      </td>
                  </tr>
                  <tr>
                      <td align="right" style="vertical-align: middle;">提示信息</td>
                      <td colspan="3" rowspan="2">
                          <div v-show="StartAutoCheckFlag" style="magin-left: 10px">{{ tips }}</div>
                          <div v-show="StartAutoCheckFlag" style="magin-left: 10px">共{{ TotalNum }}条报告,{{ UncheckNum }}条<span style="color: red">未通过</span>,{{ CheckNum }}条<span style="color: green">已通过</span></div>
                          <!-- <el-input v-model="tips" type="textarea" :rows="2" placeholder=""></el-input> -->
                      </td>
                      <td align="right" style="vertical-align: middle">标本区间</td>
                      <td style="vertical-align: top">
                          <el-input v-model="sampleno" placeholder="标本号可以输入如：1,2,5-8等格式"></el-input>
                      </td>
                      <td colspan="3" style="vertical-align: top">
                          <el-radio-group v-model="checkmode" @change="RadioChange" style="padding-top: 5px">
                              <el-radio label="1">审核模式</el-radio>
                              <el-radio label="2">仅判定</el-radio>
                              <el-radio label="3" v-show="showsignmode == '1'">{{ signlabel }}</el-radio>
                          </el-radio-group>
                      </td>
                  </tr>
              </table>
          </div>
          <div style="width:100%;float:left">
              <table style="float:right">
                  <tr>
                      <td>
                          <el-button type="primary" @click="Query">查询</el-button>
                      </td>
                      <td>
                          <el-button @click="ChangeStartFlag()">{{ StartAutoCheckFlag?'停止自动审核':'开始自动审核' }}</el-button>
                      </td>
                  </tr>
              </table>

          </div>
      </div>
      <div class="pagecenter">
          <rm-layout-right splitcolor="#FFFFFF" movingcolor="#66CCFF" :splitwidth=5 :fixsize=400>
              <template v-slot:fix>
                  <vxe-table :data.sync="RightTableData" height="auto" highlight-current-row :loading="resultloading" highlight-hover-row highlight-hover-column resizable show-header-overflow="tooltip" border fit show-overflow="tooltip" header-align="center" size="mini" stripe ref="xTable2">
                      <vxe-table-column type="index" title="NO." width="60" align="center"></vxe-table-column>
                      <!--如果在循环里面这样加，双击表头会消失，暂时去除-->
                      <!-- <vxe-table-column :field="items.field" :key="items.field" :title="items.title" :width="items.width" sortable v-for="(items) in RightTableColumn" :formatter="formatterFun"></vxe-table-column> -->
                      <vxe-table-column field="rpt_itemname" sortable title="检验项目" width="220" show-overflow>
                          <template v-slot="{ row }">
                              <div v-if="row.alertflag == '1'" style="background:red;padding:0px 10px">{{ row.rpt_itemname }}</div>
                              <div v-else style="padding:0px 10px">{{ row.rpt_itemname }}</div>
                          </template>
                      </vxe-table-column>
                      <vxe-table-column field="result_str" sortable title="检测结果" width="80" show-overflow>
                          <template v-slot="{ row }">
                              <div :style="{background: row.cp_resultbackgroundcolor,color: row.cp_resultcolor}" style="padding:0px 10px">{{ row.result_str }}</div>
                          </template>
                      </vxe-table-column>
                      <vxe-table-column field="result_unit" sortable title="单位" width="70" show-overflow></vxe-table-column>
                      <vxe-table-column field="result_ref" sortable title="参考值" width="100" show-overflow></vxe-table-column>
                      <vxe-table-column field="result1" :title="result1text" width="70px" v-if="result1 == 1"></vxe-table-column>
                      <vxe-table-column field="result2" :title="result2text" width="70px" v-if="result2 == 1"></vxe-table-column>
                      <vxe-table-column field="result3" :title="result3text" width="70px" v-if="result3 == 1"></vxe-table-column>
                      <vxe-table-column field="result_txt" sortable title="大文本结果" width="130" show-overflow></vxe-table-column>
                      <vxe-table-column field="instrid" sortable title="检验仪器" width="100" show-overflow></vxe-table-column>
                      <vxe-table-column field="interno" sortable title="通道号" width="100" show-overflow></vxe-table-column>
                      <vxe-table-column field="alertflag" align="center" sortable title="危急标志" width="60" show-overflow></vxe-table-column>
                      <vxe-table-column field="result_flag" align="center" sortable title="结果标志" width="60" show-overflow></vxe-table-column>
                      <vxe-table-column field="redo_flag" align="center" sortable title="复查标志" width="60" show-overflow></vxe-table-column>
                      <vxe-table-column field="redo_result" sortable title="复查前结果" width="120" show-overflow></vxe-table-column>
                      <vxe-table-column field="orig_result_num" sortable title="原始数值结果" width="120" show-overflow></vxe-table-column>
                      <vxe-table-column field="orig_result_str" sortable title="原始文本结果" width="120" show-overflow></vxe-table-column>
                      <vxe-table-column field="modify_flag" align="center" sortable title="修改标志" width="60" show-overflow></vxe-table-column>
                      <vxe-table-column field="first_dt" align="center" ortable title="第一次填入时间" width="120" show-overflow></vxe-table-column>
                      <vxe-table-column field="last_dt" align="center" sortable title="最后修改时间" width="120" show-overflow></vxe-table-column>
                      <vxe-table-column field="last_user" align="center" sortable title="最后修改人" width="80" show-overflow></vxe-table-column>
                      <vxe-table-column field="rptunitid" sortable title="报告单元" width="150" show-overflow></vxe-table-column>
                      <vxe-table-column field="germflag" align="center" sortable title="细菌标志" width="60" show-overflow></vxe-table-column>
                      <vxe-table-column field="orig_result_flag" align="center" sortable title="原始结果标志" width="160" show-overflow></vxe-table-column>
                  </vxe-table>
              </template>
              <div style="height:100%;width:100%;background-color:#ddccbb;">
                  <vxe-table show-overflow ref="xTable1" height="auto" :loading="reportloading" :cell-class-name="cellClassName" :sort-config="{trigger: 'cell'}" :data.sync="LeftTableData" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe @current-change="currentChangeEvent" header-align="center">
                      <vxe-table-column field="createtime" title="创建时间" width="120" align="center"></vxe-table-column>
                      <vxe-table-column field="chkresult" title="自动审核结果" width="160" align="center"></vxe-table-column>
                      <vxe-table-column field="chktime" title="自动审核时间" width="120" align="center"></vxe-table-column>
                      <vxe-table-column field="rptunitid" title="报告单元" width="60" align="center"></vxe-table-column>
                      <vxe-table-column field="sampledate" title="标本日期" width="80" sortable :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                      <vxe-table-column field="sampleno" title="标本编号" width="60" align="center"></vxe-table-column>
                      <vxe-table-column field="barcode" title="条码号" width="80"></vxe-table-column>
                      <vxe-table-column field="pat_typename" title="病人类别" width="60" align="center"></vxe-table-column>
                      <vxe-table-column field="chkflag" title="自动审核标志" width="120" align="center">
                          <template v-slot="{ row }">
                              <div v-if="row.chkflag == '1'" style="background-color:#67C23A;color: white">通过</div>
                              <div v-else-if="row.chkflag == '0'">待审核</div>
                              <div v-else-if="row.chkflag == '2'" style="background-color:#F56C6C;color: white">不通过</div>
                              <div v-else-if="row.chkflag == '9'" style="background-color:#F56C6C">不参与审核</div>
                          </template>
                      </vxe-table-column>
                      <vxe-table-column field="reportid" title="报告ID" width="100"></vxe-table-column>
                      <vxe-table-column field="rechk_dt" title="标本审核时间" width="80" :formatter="['toDateString', 'yyyy-MM-dd']" align="center"></vxe-table-column>
                      <vxe-table-column field="rechk_username" title="审核者" width="60" align="center"></vxe-table-column>
                      <vxe-table-column field="report_username" title="检验者" width="60" align="center"></vxe-table-column>
                      <vxe-table-column field="req_deptno" title="申请科室" width="60" align="center"></vxe-table-column>
                  </vxe-table>
              </div>
          </rm-layout-right>
      </div>
      <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="multichktitle" :visible.sync="dialogMultipleVisible" :destroy-on-close="true" v-if="dialogMultipleVisible">
          <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname" @change="closedialog"></rm-SqlMultiple>
      </el-dialog>

      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="系统注册" :show-close="false" :visible.sync="RegVisible" width="60%">
          <span style="color:#0095d9">请输入注册码</span>
          <el-input type="textarea" :rows="8" v-model="RegCodestr" style="margin-top: 5px"></el-input>
          <div style="text-align:right;margin-top: 5px">
              <el-button @click="SaveReg()">确定</el-button>
              <el-button @click="RegClose()">取消</el-button>
          </div>
      </el-dialog>
  </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils";
export default {
  name: "LIS334",
  data() {
      return {
          rptunitid: "",
          instrid: "",
          pattype: "",
          tips: "",
          sampleno: "",
          rptunitOption: [],
          pattypeOption: [],
          instrOption: [],
          begindate: "",
          enddate: "",
          checkuser: "",
          checkuserno: "",
          reportuser: "",
          reportuserno: "",
          resultloading: false,
          reportloading: false,
          checkmode: "2", //审核模式
          oldcheckmode: "2", //旧审核模式

          result1text: "",
          result2text: "",
          result3text: "",
          result1: "",
          result2: "",
          result3: "",

          xTable1loading: false,
          xTable2loading: false,
          LeftTableData: [],
          RightTableData: [],

          option1: [],
          option2: [],
          fieldname: "",
          multichktitle: "",
          dialogMultipleVisible: false,
          StartAutoCheckFlag: false,
          TotalNum: 0,
          CheckNum: 0,
          UncheckNum: 0,
          timeoutid: 0,
          //lastreportid: "",//一次查询得到的最后一个报告报告id
          CheckingFlag: false, //正在审核标志
          //添加 解决审核数据异步提交的问题
          CheckData: [], //待审核的数据
          checkindex: 0, //带审核数据index
          useca: "0",
          showsignmode: "0",

          RegVisible: false,
          RegCodestr: "",

          signlabel: "签名模式" //签名模式初审模式的文字显示
      };
  },
  created() {
      if(localStorage.getItem("RM_LIS334_CHECKMODE")) this.checkmode = localStorage.getItem("RM_LIS334_CHECKMODE");
      this.InitPage(); //初始化查询
  },
  beforeDestroy() {
      let data = { rptunitid: this.rptunitid, pat_typecode: this.pattype, instrid: this.instrid, checkmode: this.checkmode };
      this.$tool.setSession("LIS334_Query", data);
      clearTimeout(this.timeoutid);
  },
  mounted() {
      this.CheckReg().then(() => {
          this.LoginPage();
      });
  },
  updated() {},
  methods: {
      AutoAutoCheck() {
          let that = this;
          this.AutoCheckTimeOut().finally(e => {
              this.timeoutid = setTimeout(() => {
                  that.AutoAutoCheck();
              }, 10000);
          });
      },
      async AutoCheckTimeOut() {
          if (this.StartAutoCheckFlag) {
              if (this.CheckingFlag) return; //如果正在审核则不做查询
              var rcnt = await this.$tool.request({ url: "LIS/LIS3/LIS334", method: "post", data: { action: "querylist", rptunitid: this.rptunitid, begindate: this.begindate, enddate: this.enddate, instrid: this.instrid, sampleno: this.sampleno, pattypecode: this.pattype, checkmode: this.checkmode } });
              if (rcnt && rcnt.dt) {
                  // for (let i = 0; i < rcnt.dt.length; i++) {
                  //     if (!this.LeftTableData.find((m) => m.reportid == rcnt.dt[i].reportid)) {
                  //         this.LeftTableData.unshift(rcnt.dt[i]);
                  //     }
                  // }
                  this.LeftTableData = rcnt.dt;
                  let date = XEUtils.toDateString(new Date(), "yyyy-MM-dd HH:mm:ss");
                  this.tips = "开始自动审核：" + date;
                  this.$nextTick(() => {
                      this.CheckNum = rcnt.dt.filter(item => item.chkflag == "1").length;
                      this.UncheckNum = rcnt.dt.filter(item => item.chkflag == "2" || item.chkflag == "9").length;
                      // var uncheckdt = rcnt.dt.filter((item) => item.chkflag == "0");
                      // if(uncheckdt[uncheckdt.length - 1].hasOwnProperty("reportid")) {
                      //     this.lastreportid = uncheckdt[uncheckdt.length - 1].reportid;
                      // }
                      // else {
                      //     this.lastreportid = "";
                      // }
                      this.TotalNum = this.LeftTableData.length;
                      this.BeginCheck();
                  });
              }
          }
      },
      LoginPage(type) {
          if (this.StartAutoCheckFlag) return;
          this.$rm_Login({
              type: "请输入工号和密码",
              modal: type ? false : true,
              btn: {
                  confirmBtnText: "确定",
                  cancelBtnText: "取消"
              }
          })
              .then(res => {
                  if (res.flag == "1") {
                      let data = this.$tool.getSession("LIS334_Query");
                      if (data) {
                          this.rptunitid = data.rptunitid;
                          if (this.rptunitid != "") this.InitInstr(this.rptunitid);
                          this.pattype = data.pat_typecode;
                          this.instrid = data.instrid;
                          this.checkmode = data.checkmode;
                      }
                      if (!type) {
                          this.reportuser = this.$tool.getSession(this.$tool.loginusername);
                          this.reportuserno = this.$tool.getSession(this.$tool.loginuserno);
                          this.checkuser = res.username;
                          this.checkuserno = res.userid;
                      } else if (type == 1) {
                          this.checkuser = res.username;
                          this.checkuserno = res.userid;
                      } else if (type == 2) {
                          this.reportuser = res.username;
                          this.reportuserno = res.userid;
                      }

                      this.checkCaLogin(this.checkuserno).then(res => {
                          if (res.flag != 1) {
                              this.$alert(res.msg, "提示")
                                  .then(() => {
                                      let index = this.$parent.$refs.itemtags.tagsList.findIndex(m => m.name == "LIS334");
                                      this.$parent.$refs.itemtags.tagsList.splice(index, 1);
                                      this.$router.go(-1);
                                  })
                                  .catch(() => {
                                      let index = this.$parent.$refs.itemtags.tagsList.findIndex(m => m.name == "LIS334");
                                      this.$parent.$refs.itemtags.tagsList.splice(index, 1);
                                      this.$router.go(-1);
                                  });
                          }
                      });
                      //this.AutoAutoCheck();
                  } else {
                      // let index = this.$parent.$refs.itemtags.tagsList.findIndex((m) => m.name == "LIS334");
                      // this.$parent.$refs.itemtags.tagsList.splice(index, 1);
                      // this.$router.go(-1);
                      //window.close();
                      //this.$router.go(-1);
                  }
              })
              .catch(e => {
                  if (!type) {
                      let index = this.$parent.$refs.itemtags.tagsList.findIndex(m => m.name == "LIS334");
                      this.$parent.$refs.itemtags.tagsList.splice(index, 1);
                      this.$router.go(-1);
                  }
              });
      },
      InitPage() {
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS334",
                  method: "post",
                  data: {
                      action: "initpage"
                  }
              })
              .then(res => {
                  if (res && !res.hasOwnProperty("errcode")) {
                      this.rptunitOption = res.rptunitOption;
                      this.pattypeOption = res.pattypeOption;
                      //this.instrOption = res.instrOption;
                      this.enddate = res.datetime;
                      this.useca = res.useca;
                      this.showsignmode = res.showsign;
                  }
              });
      },

      InitInstr(rptunitid) {
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS334",
                  method: "post",
                  data: {
                      action: "initpage",
                      rptunitid: rptunitid
                  }
              })
              .then(res => {
                  if (res && !res.hasOwnProperty("errcode")) {
                      this.instrOption = res.instrOption;
                      if (res.showsingnlabel) {
                          //var buttonarr = res.buttonlstr.split(",");
                          if (res.showsingnlabel.indexOf("初审") > -1) {
                              this.signlabel = "初审模式";
                          } else {
                              this.signlabel = "签名模式";
                          }
                      } else {
                          this.signlabel = "签名模式";
                      }
                  }
              });
      },
      rptunitchange(val) {
          this.InitInstr(val);
      },
      popMultipleChk(e, fieldname, option, title) {
          if (fieldname == "instrid" && this.rptunitid == "") {
              this.$alert("请选择报告单元后再选择仪器!");
              return;
          }
          if (this.StartAutoCheckFlag) return;
          let temp = XEUtils.clone(option, true);
          this.option1 = [];
          this.option2 = [];
          if (e != "") {
              let k = e.split(",");
              k.forEach(item => {
                  let ndata = temp.find(m => m.data == item);
                  if (ndata != undefined && ndata != null) {
                      this.option2.push(ndata);
                  }
              });
              temp.forEach(item => {
                  if (k.indexOf(item.data + "") < 0) {
                      this.option1.push(item);
                  }
              });
          } else {
              this.option1 = temp;
          }
          this.fieldname = fieldname;
          this.multichktitle = title;
          this.dialogMultipleVisible = true;
      },
      closedialog(value, name) {
          if (value != "close") {
              this[name] = value;
              if (name == "rptunitid") this.rptunitchange(value);
          }
          this.dialogMultipleVisible = false;
      },

      Query() {
          this.reportloading = true;
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS334",
                  method: "post",
                  data: {
                      action: "querylist",
                      rptunitid: this.rptunitid,
                      begindate: this.begindate,
                      enddate: this.enddate,
                      instrid: this.instrid,
                      sampleno: this.sampleno,
                      pattypecode: this.pattype,
                      checkmode: this.checkmode
                  }
              })
              .then(res => {
                  if (res && !res.hasOwnProperty("errcode") && res.dt) {
                      this.LeftTableData = res.dt;
                      this.TotalNum = res.dt.length;
                      this.CheckNum = res.dt.filter(item => item.chkflag == "1").length;
                      this.UncheckNum = res.dt.filter(item => item.chkflag == "2" || item.chkflag == "9").length;
                  }
                  this.reportloading = false;
              })
              .catch(e => {
                  this.reportloading = false;
              });
      },
      QueryResult(row) {
          this.resultloading = true;
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS334",
                  method: "post",
                  data: {
                      action: "get_labresult",
                      reportid: row.reportid,
                      rptunitid: row.rptunitid
                  }
              })
              .then(res => {
                  if (res && res.errcode == "1") {
                      this.RightTableData = res.rtn[0];
                      this.result1text = res.result1text;
                      this.result2text = res.result2text;
                      this.result3text = res.result3text;
                      this.result1 = res.result1;
                      this.result2 = res.result2;
                      this.result3 = res.result3;
                      this.resultloading = false;
                  }
              })
              .catch(e => {
                  this.$message.error(e);
                  this.resultloading = false;
              });
      },
      AutoCheck(reportid) {
          if (this.StartAutoCheckFlag) {
              this.$tool
                  .request({
                      url: "LIS/LIS3/LIS334",
                      method: "post",
                      data: {
                          action: "autocheckreport",
                          reportid: reportid,
                          reportuser: this.reportuserno,
                          checkuser: this.checkuserno,
                          autocheckmode: this.checkmode
                      }
                  })
                  .then(res => {
                      let reportindex = this.LeftTableData.findIndex(m => m.reportid == reportid);
                      if (res && res.flag == "1") {
                          this.ReportCheckCA(res, "", this.checkuserno)
                              .then(() => {
                                  this.LeftTableData[reportindex].chkresult = "审核成功!";
                                  this.LeftTableData[reportindex].chktime = res.chktime;
                                  this.LeftTableData[reportindex].chkflag = res.flag;
                                  this.CheckNum++;
                              })
                              .catch(() => {
                                  this.LeftTableData[reportindex].chkresult = "审核成功,CA签名失败!";
                                  this.LeftTableData[reportindex].chktime = res.chktime;
                                  this.LeftTableData[reportindex].chkflag = res.flag;
                                  this.CheckNum++;
                              });
                      } else {
                          this.LeftTableData[reportindex].chkresult = res.msg;
                          this.LeftTableData[reportindex].chkflag = res.flag;
                          this.LeftTableData[reportindex].chktime = res.chktime;
                          this.UncheckNum++;
                      }
                      this.checkindex++;
                      if (this.checkindex < this.CheckData.length) {
                          this.AutoCheck(this.CheckData[this.checkindex].reportid);
                      } else {
                          this.CheckingFlag = false;
                      }
                  })
                  .catch(e => {
                      this.$message.error(e);
                  });
          }
      },
      CheckReg() {
          return new Promise((s, f) => {
              this.$tool
                  .request({
                      url: "LIS/LIS3/LIS334",
                      method: "post",
                      data: {
                          action: "regresister"
                      }
                  })
                  .then(res => {
                      if (res.errcode != "1") {
                          this.$confirm("自动审核未注册，是否输入注册码?", {
                              confirmButtonText: "确定",
                              cancelButtonText: "取消",
                              type: "warning"
                          })
                              .then(() => {
                                  this.RegVisible = true;
                                  f();
                              })
                              .catch(() => {
                                  let index = this.$parent.$refs.itemtags.tagsList.findIndex(m => m.name == "LIS334");
                                  this.$parent.$refs.itemtags.tagsList.splice(index, 1);
                                  this.$router.go(-1);
                              });
                      } else {
                          s();
                      }
                  });
          });
      },
      SaveReg() {
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS334",
                  method: "post",
                  data: {
                      action: "savereg",
                      regcode: this.RegCodestr
                  }
              })
              .then(res => {
                  if (res.flag == "1") {
                      this.RegVisible = false;
                      this.$message.success("注册成功");
                      this.LoginPage();
                  } else {
                      this.$alert("注册码错误!", "提示");
                  }
              });
      },
      RegClose() {
          let index = this.$parent.$refs.itemtags.tagsList.findIndex(m => m.name == "LIS334");
          this.$parent.$refs.itemtags.tagsList.splice(index, 1);
          this.$router.go(-1);
      },
      BeginCheck() {
          let data = this.$refs.xTable1.tableFullData.filter(item => item.chkflag == "0");
          if (data.length > 0) {
              this.CheckingFlag = true;
              this.CheckData = data;
              this.checkindex = 0;
              this.AutoCheck(this.CheckData[this.checkindex].reportid);
          } else {
              this.CheckData = [];
          }
          //循环做自动审核存在多提交问题不可取
          // for (let i = 0; i < data.length; i++) {
          //     this.AutoCheck(data[i].reportid);
          // }
      },
      ChangeStartFlag() {
          this.StartAutoCheckFlag = !this.StartAutoCheckFlag;
          if (this.StartAutoCheckFlag) {
              let date = XEUtils.toDateString(new Date(), "yyyy-MM-dd HH:mm:ss");
              this.tips = "开始自动审核：" + date;
              this.oldcheckmode = XEUtils.clone(this.checkmode, true);
              this.AutoAutoCheck();
          } else {
              this.tips = "";
              this.CheckingFlag = false;
              clearTimeout(this.timeoutid);
          }
      },
      currentChangeEvent({ row }) {
          this.QueryResult(row);
      },
      RadioChange(val) {
          if (this.StartAutoCheckFlag) {
              this.$alert("请先停止自动审核!");
              this.checkmode = XEUtils.clone(this.oldcheckmode, true);
          } else {
              if (val == "1") this.$alert("符合自动审核规则的报告将被置为【已审核】状态，需要登录检验者和审核者", "提示"); //审核模式
              if (val == "2") this.$alert("仅判定自动审核规则是否通过，不会修改报告的状态", "提示"); //仅判定模式
              if (val == "3") this.$alert("符合自动审核规则的报告将被置为【已"+signlabel.replace('模式', '')+"】状态，需要登录检验者", "提示"); //签名模式
          }
          localStorage.setItem("RM_LIS334_CHECKMODE", val);
      },
      cellClassName({ row, column }) {
          if (column.property == "redo_flag") {
              if (row.redo_flag == "1") {
                  return "col-yellow";
              } else {
                  return "";
              }
          } else if (column.property == "emer_flag") {
              if (row.emer_flag == "1") {
                  return "col-green";
              } else {
                  return "";
              }
          } else if (column.property == "warn_flag") {
              if (row.warn_flag == "1") {
                  console.log("row.warn_flag ", row.warn_flag);
                  return "col-red";
              } else {
                  return "";
              }
          }
      },
      //CA
      ReportCheckCA(res, tp, rechkuser) {
          return new Promise((s, f) => {
              if (res.hasOwnProperty("checkca") && res.checkca == "1") {
                  //CA信息保存先异步吧，和审核报告区分开来，就算签名失败也不影响审核，以免以后CA出故障导致一直无法审核报告
                  let chkuser = rechkuser;
                  //CA签名数据保存，不管成功或失败，都不影响审核 加密和保存加密数据都集成到CAsign方法
                  this.$ca.CAsign(chkuser, res.reporttoca.data, res.reporttoca.reportid).then(caret => {
                      //this.$pub.Log("电子签名结束");
                      if (caret.flag != "1") {
                          this.$pub.Log("CA签名失败：chkuser=" + chkuser + "reportid = " + res.reporttoca.reportid + ",data=" + res.reporttoca.data);
                          f();
                      } else {
                          s();
                      }
                  });
              } else {
                  s();
              }
          });
      },
      checkCaLogin(rckuser) {
          return new Promise((s, f) => {
              if (this.useca == "1") {
                  this.$ca.checklogin("rptchk", rckuser).then(cares => {
                      s(cares);
                  });
              } else {
                  s({ flag: "1" });
              }
          });
      }
  }
};
</script>

<style scoped>
.pagetop {
  width: 100%;
  height: 130px;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  z-index: 99;
}

.pagecenter {
  position: absolute;
  top: 134px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}
/deep/ .vxe-table .vxe-body--column.col-red {
  background-color: #990033;
}
/deep/ .vxe-table .vxe-body--column.col-yellow {
  background-color: #999900;
}
/deep/ .vxe-table .vxe-body--column.col-green {
  background-color: #00ffcc;
}

/deep/.vxe-cell .el-checkbox__inner::after {
  border: 2px solid #000000 !important;
  box-sizing: content-box;
  content: "";
  border-left: 0 !important;
  border-top: 0 !important;
  height: 7px;
  left: 4px;
  position: absolute;
  top: 1px;
  transform: rotate(45deg) scaleY(0);
  width: 3px;
  transition: transform 0.15s ease-in 0.05s;
  transform-origin: center;
}
/deep/.vxe-cell .el-checkbox__input.is-disabled + span.el-checkbox__label {
  color: #000000;
  cursor: not-allowed;
}
/deep/.vxe-cell .el-checkbox__input.is-disabled .el-checkbox__inner,
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner + .el-input.is-disabled .el-input__inner {
  background-color: #ffffff !important;
}
</style>
